Cleaning up
[andmenj-acm.git] / 10049 - Self-Describing Sequence / p10049.cpp
blob6b8a81a299087b693c8e28800120a44033587c08
1 #include <cstdlib>
2 #include <iostream>
3 #include <vector>
4 #include <math.h>
6 using namespace std;
8 vector<int> cambios;
10 int f(const int &n){
11 int i=0;
12 while (n >= cambios[i] && i < cambios.size()){
13 i++;
15 //for (i=0; n >= cambios[i]; i++);
16 //cout << "f("<< n << ") = " << i << endl;
17 return i;
20 void printCambios(){
21 for (int i = 0; i<cambios.size(); i++){
22 cout << cambios[i] << " ";
24 cout << endl;
28 void crearCambios(){
29 cambios.push_back(1);
30 cambios.push_back(2);
31 cambios.push_back(4);
32 cambios.push_back(6);
33 cambios.push_back(9);
34 //while(cambios[cambios.size()-1] < 20000000){
35 while (cambios.size() < 700){
36 int ultimo = cambios[cambios.size()-1];
37 cambios.push_back(ultimo + f(f(ultimo)));
39 cout << "El tamaƱo de cambios es: " << cambios.size() << endl;
42 int main(int argc, char *argv[])
44 //crearCambios();
45 //printCambios();
46 system("PAUSE");
47 return EXIT_SUCCESS;